using UnityEngine;
using System.Collections;

public class Tiro_Alvo : MonoBehaviour
{
    int id = 17;

    void Start()
    {
        this.gameObject.AddComponent("MeshRenderer");
        this.gameObject.AddComponent("MeshFilter");
        this.gameObject.AddComponent("SphereCollider");
        //this.gameObject.AddComponent("Rigidbody");

        this.gameObject.tag = "Alvo10";

        this.gameObject.GetComponent<SphereCollider>().radius = 2.72f;
        this.gameObject.GetComponent<SphereCollider>().center = new Vector3(0.13f, 0, 0);
        this.gameObject.GetComponent<SphereCollider>().isTrigger = true;

        /*this.gameObject.GetComponent<Rigidbody>().useGravity = false;
        this.gameObject.GetComponent<Rigidbody>().isKinematic = true;
        this.gameObject.GetComponent<Rigidbody>().freezeRotation = true;*/

        this.transform.localPosition = new Vector3(0, 0.1f, 0);

        Mesh mesh = Quad.Create(8f, 6f);

        this.gameObject.GetComponent<MeshFilter>().mesh = mesh;
        this.gameObject.GetComponent<MeshRenderer>().material = AtlasManager.globalMaterial;

        this.gameObject.GetComponent<MeshFilter>().mesh.uv = new Vector2[]
		{
			new Vector2(AtlasManager.rects[id].xMin, AtlasManager.rects[id].yMax),
			new Vector2(AtlasManager.rects[id].xMax, AtlasManager.rects[id].yMax),
			new Vector2(AtlasManager.rects[id].xMax, AtlasManager.rects[id].yMin),
			new Vector2(AtlasManager.rects[id].xMin, AtlasManager.rects[id].yMin)
		};
    }

    void Update()
    {
        //this.transform.localPosition = new Vector3(0, 0.1f, 0);
    }
    //void OnTriggerEnter(Collider c)
    //{
    //    if (c.gameObject.tag == "Player")
    //    {
    //        Game_Tiro.colidindo = true;
    //    }
    //    else { Game_Tiro.colidindo = false; }
    //}
}
